﻿using Coldairarrow.Business.View;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.View;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.View
{
    [Route("/View/[controller]/[action]")]
    public class View_PB_MaterialStockNumberController : BaseApiController
    {
        #region DI

        public View_PB_MaterialStockNumberController(IView_PB_MaterialStockNumberBusiness view_PB_MaterialStockNumberBus)
        {
            _view_PB_MaterialStockNumberBus = view_PB_MaterialStockNumberBus;
        }

        IView_PB_MaterialStockNumberBusiness _view_PB_MaterialStockNumberBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<View_PB_MaterialStockNumber>> GetDataList(PageInput<QueryPBMaterialType> input)
        {
            return await _view_PB_MaterialStockNumberBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<View_PB_MaterialStockNumber> GetTheData(IdInputDTO input)
        {
            return await _view_PB_MaterialStockNumberBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(View_PB_MaterialStockNumber data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _view_PB_MaterialStockNumberBus.AddDataAsync(data);
            }
            else
            {
                await _view_PB_MaterialStockNumberBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _view_PB_MaterialStockNumberBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}